<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;

        vertical-align: middle;
      }
      /* body {
        vertical-align: middle;
      } */
      input {
        height: 30px;
        width: 200px;
        border: solid 1px #999;
        vertical-align: middle;
      }
      button {
        background-color: blue;
        color: #fff;
        width: 60px;
        height: 30px;
        outline: none;
        border: blue;
      }
    </style>
  </head>
  <body>
    <input type="text" value="邮箱/id/手机号" id="user" />
    <input type="text" id="pwd" value="密码" />
    <button id="login">登录</button>
    <script>
      var userName = document.getElementById('user')
      var pwd = document.getElementById('pwd')
      userName.onfocus = function () {
        this.value = ''
      }
      userName.onblur = function () {
        if (this.value.trim().length === 0) {
          this.value = '邮箱/id/手机号'
        }
      }
      pwd.onfocus = function () {
        this.value = ''
        this.type = 'password'
      }
      pwd.onblur = function () {
        if (this.value.trim().length === 0) {
          this.type = 'text'
          this.value = '密码'
        }
      }
    </script>
  </body>
</html>
